<template>
	<view class="accounts-security">
		<view class="mb10">
			<view class="settings-line space-between" @click="jumpPath('/pages/subpackage/my/editPhone')">
				<view class="fz16">
					修改手机号
				</view>
				<view class="flex align-c">
					<view class="c9 fz13 mr10">
						{{phone}}
					</view>
					<image src="../../../static/my/right_icon.png" mode=""></image>
				</view>
			</view>

			<view class="settings-line space-between" @click="jumpPath('/pages/subpackage/my/loginPassword')">
				<view class="fz16">
					登录密码
				</view>
				<image src="../../../static/my/right_icon.png" mode=""></image>
			</view>

			<view class="settings-line space-between" @click="jumpPath('/pages/subpackage/my/paymentPassword')">
				<view class="fz16">
					支付密码
				</view>
				<image src="../../../static/my/right_icon.png" mode=""></image>
			</view>
		</view>

		<view class="log-out-btn fz18 bold" @click="zhux">
			注销账户
		</view>
	</view>
</template>

<script>
	import {
		ruin,
		userLogout,
	} from '@/network/loginAndMy.js'
	import {
		config
	} from '@/network/api.js'
	export default {
		data() {
			return {
				phone: '', // 用户手机号,
				applyStatus:'',//1显示，0不显示
			}
		},
		onLoad() {
			this.peizRe()
		},
		onShow() {
			let show_phone = uni.getStorageSync('phone');
			this.phone = `${show_phone.slice(0,3)}****${show_phone.slice(show_phone.length-4,show_phone.length)}`
		},
		methods: {
			// 跳转页面
			jumpPath(path) {
				uni.navigateTo({
					url: path
				});
			},
			// 注销账户
			zhux(){
				ruin().then(res=>{
					if(res.code==1){
						this.logOut()
					}
				})
			},
			peizRe(){
				config().then(res=>{
					if(res.code==1){
						this.applyStatus=res.data.applyStatus
						console.log(res,'配置')
					}
				})
			},
			// 退出登陆
			logOut() {
				userLogout().then(res => {
					if (res.code == 1) {
						uni.$TUIKit.logout().then(imResponse => {
							uni.showToast({
								title: "退出成功",
								icon: "none",
								duration: 2000,
							});
						});
						uni.removeStorageSync('token');
						uni.removeStorageSync('token1');
						uni.removeStorageSync('phone');
						uni.reLaunch({
							url: '/pages/subpackage/landing_operation/logIn'
						});
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.accounts-security {
		background-color: #F3F3F3;
		height: 100vh;
		padding-top: 20rpx;
		.settings-line{
			background-color: #ffffff;
			height: 110rpx;
			padding: 0 30rpx;
			box-sizing: border-box;
			position: relative;
			image{
				width: 30rpx;
				height: 30rpx;
			}
		}
		
		.settings-line::after {
			content: "";
			width: calc(100vw - 30rpx);
			height: 2rpx;
			background-color: #F2F2F2;
			position: absolute;
			bottom: 0;
			left: 50%;
			transform: translateX(-50%);
		}
		
		.settings-line:last-child::after {
			content: "";
			background-color: transparent;
		}
		
		.log-out-btn{
			height: 80rpx;
			width: 100%;
			text-align: center;
			line-height: 80rpx;
			background-color: #ffffff;
		}
	}
</style>